/// Coder: Jose Ricardo Mello Viana - 2008
/// Bugs? e-mail me: zezim.ricardo@gmail.com

/**
 *
 * Author: Jose Ricardo (zezim)
 *
 * Data created: 16-05-08
 *
 **/

#ifndef COLORBUFFER_H_
#define COLORBUFFER_H_

#include "geomTypes/geomTypes.h"
#include "glslKernel/glslKernel.h"
#include "paintCursor.h"

#include "fboClass/framebufferObject.h"
#include "fboClass/renderbuffer.h"
#include "fboClass/glErrorUtil.h"

#include <vector>
#include <queue>
#include <GL/glut.h>

#define PI 3.1415926535897932384626433832795

using namespace std;

typedef float Number;
typedef Point<2, int> Point2i;
typedef Point<3, Number> Point3;
typedef Vector<2, int> Vector2i;
typedef Vector<3, Number> Vector3;
typedef Vector<4, Number> Color;

class ColorBuffer {
public:
   /// Default constructor
   ColorBuffer();

   /// Constructor parsing cursor
   /// @param p given paintcursor
   /// @param w given width of buffer
   /// @param h given height of buffer
//   ColorBuffer(PaintCursor *p, int w, int h);
   ColorBuffer(PaintCursor *p, GLuint t);

   /// Default destructor
   virtual ~ColorBuffer();

   void clean();

   /// Paint current cursor position
   void paint();

   void setFBO(FramebufferObject f) { fbo = f; };

   void setTexture(GLuint t) { tex = t; };

   /// Draw color buffer - with illumination
   void draw();

   void drawTexture(float angX, float angY);

   Point2i getMaxi() { return maxi; };

   Point2i getMini() { return mini; };

private:
   GLuint tex;
   FramebufferObject fbo;

   PaintCursor *pc;
   int bh, bw;

   glslKernel* shader_buffer;

   Point2i  maxi,
            mini;

};

#endif /*COLORBUFFER_H_*/
